$(function () {
    var user = localStorage.getItem("user")
    if(user){
        $(".user").html(user)
        $(".login").remove()
        $(".register").remove()
        $(".logininfo").html('<a href="#" class="login-out">退出</a>')
        
    }
    $(".logininfo").on("click",".login-out",function(){
        localStorage.removeItem("user")
        window.location.reload();
    })
    $.ajax({
        url: "http://localhost/yidianzu/API/addedservice.php",
        type: "get",
        dataType:"json",
        success: function (data) {
            var data = data
            console.log(data)
                
                var html = ""
                for (var i = 0; i < data.length; i++) {
                    html = `
                    
                    <a href="#">
                        <img src="${data[i].img_url}" alt="">
                        <p class="otherTit">${data[i].title}</p>
                        <p class="otherPrice">${data[i].price}</p>
                        <span>立即锁定</span>
                    </a>
                    
                `
                $(".other").eq(i).html(html)
                console.log(html)
                }
                // console.log($(".other").eq(i).html(html))
                
            }

        
    })

})